<!-- 巡检 -->
<template>
	<view style="height: 100vh; background-color: #FFFFFF;">
		<!--  -->
		<u-navbar title-color="#FFFFFF" height="48" back-icon-color="#FFFFFF" :border-bottom="false" :is-fixed="true" :title="'巡检记录'"></u-navbar>
		<uc-content :loading="loading">
			<!--无数据列表页面-->
			<view v-if="fireHazardsList.length<1" class="view-center">
				<u-empty text="暂无数据" mode="list"></u-empty>
			</view>
			<view v-else>
				<view class="list-item" v-for="(item,index) in fireHazardsList" :key="index" @click="checkItem(item)">
					<view class="list-top ">
						<view class="list-left">{{ item.name }}</view>
					</view>
					<view class="list-center u-line-3">
						<view>设备名称:{{item.equipmentName}}</view>
						<view>所属企业:{{item.enterpriseName}}</view>
						<view>设备状态:{{item.equipmentStatus|equipmentStatus}}</view>
					</view>
					<!-- <view class="list-bottom">
						<view>内容:{{item.content}}</view>
					</view> -->
				</view>
				<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
			</view>
		</uc-content>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loading:false,
				equipmentId:null,
				InspectionList: [],
				pageNum:0,
				finished:false,
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '没有更多数据了'
				}
			}
		},
		onLoad(e) {
			console.log(e)
			this.equipmentId = e.ucId || null
		},
		onShow() {
			this.initView()
		},
		methods: {
			initView(val) {
				this.loading=true
				this.InspectionList = []
				this.pageNum = 0
				this.getEquipmentInspectionPage()
			},
			//获取设备分页信息数据
			getEquipmentInspectionPage(){
				this.pageNum++  
				let _this = this
				return new Promise((resolve, reject) => {
					_this.utils.request("/api/app/Inspection/getEquipmentInspectionPage", {pageNum:this.pageNum,pageSize:10,deleted:false,equipmentId:this.equipmentId	}, "post", "app", true).then(res => {
						console.log(res.data)
						_this.InspectionList.push(...res.data.list)
						_this.finished = (res.data.pageNum >= res.data.pages);
						if(_this.finished){
							_this.status = 'nomore';
						}
						resolve(res)
					}).catch(error => {
						reject(error)
					})
				})
			},
			onReachBottom() {
				if(this.finished) return ;
				this.status = 'loading';
				this.getEquipmentInspectionPage().then(res=>{
					if(this.finished) this.status = 'nomore';
					else this.status = 'loading';
				}).catch(error=>{
					this.status = 'nomore';
				})
			},
			addInspection(){
				uni.navigateTo({
					url:"/pages/index/equipment/Inspection/edit?ucId="+this.equipmentId
				})
			}
		}
	}
</script>

<style>
.navbar-right {
		margin-right: 24rpx;
		display: flex;
	}
</style>
